﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.DirectoryServices;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using Future.DBUtility;
using WindowsFormsApplication1.DAO;

namespace WindowsFormsApplication1
{
    public partial class LoginForm : Form
    {   
        string getuserNo, getPassword;

        LoginDAO loginDAO = new LoginDAO();
        public LoginForm()
        {
            InitializeComponent();
           
        }

        private void btn_login_Click(object sender, EventArgs e)
        {
            getuserNo = txt_userId.Text.Trim();
            getPassword = txt_pwd.Text.Trim();
            if (getPassword == "")
            {
                MessageBox.Show("密码不能为空");
            }
            else if (getuserNo == "")
            {
                MessageBox.Show("用户名不能为空");
                
            }
            else
            {
                if (loginDAO.MDBValidateUser(getuserNo, getPassword))
                {
                    MenuForm f2 = new MenuForm();
                    f2.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误");
                }
            }
        }

        /** 
         *      在用户登录时，输入密码之后按下Enter键响应登录按钮：
         * 
         * **/ 
        private void txt_pwd_KeyDown(object sender, KeyEventArgs e)
        {
            //在输入完成密码后按下enter键进入系统
            if (e.KeyCode == Keys.Enter)
            {
                //触发button点击事件
                this.btn_login_Click(sender, e);
            }

        }
    } 

}
